Skip to content

[#10808] Improvement(client-python): Add Owner management API (get_owner / set_owner)#10809

Open
sunyuhan1998 wants to merge 1 commit intoapache:mainfrom
sunyuhan1998:feature/python-sdk-owner-api
Open

[#10808] Improvement(client-python): Add Owner management API (get_owner / set_owner)#10809
sunyuhan1998 wants to merge 1 commit intoapache:mainfrom
sunyuhan1998:feature/python-sdk-owner-api

Conversation

@sunyuhan1998
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add get_owner / set_owner API to the Python SDK, aligning with the Java client's GravitinoMetalake.getOwner() / setOwner() methods.

New files:

  • gravitino/api/authorization/owner.py — Owner interface with Type enum (USER / GROUP)
  • gravitino/dto/authorization/owner_dto.py — OwnerDTO
  • gravitino/dto/requests/owner_set_request.py — setOwner request body
  • gravitino/dto/responses/owner_response.py — getOwner response
  • gravitino/dto/responses/set_response.py — setOwner response
  • gravitino/exceptions/handlers/owner_error_handler.py — Owner error handler

Modified files:

  • gravitino/client/gravitino_metalake.py — Add get_owner / set_owner methods
  • gravitino/client/gravitino_client.py — Add delegation methods

Why are the changes needed?

The Java SDK already supports ownership management, but the Python SDK lacks these APIs. Users must fall back to raw REST calls via requests, which is inconsistent with the SDK design.

Fix: #10808

Does this PR introduce any user-facing change?

Yes, two new public APIs are added:

  • GravitinoClient.get_owner(metadata_object)Optional[Owner]
  • GravitinoClient.set_owner(metadata_object, owner_name, owner_type)None

No existing APIs are changed.

How was this patch tested?

Unit tests added in tests/unittests/test_owner.py (17 test cases):

  • Integration tests: get_owner (user/group/none), set_owner (success/false)
  • Error handler tests: all 5 error code branches (ILLEGAL_ARGUMENTS, NOT_FOUND, UNSUPPORTED_OPERATION, NOT_IN_USE, INTERNAL_ERROR)
  • Validation tests: OwnerSetRequest.validate() (empty name, none type), OwnerResponse.validate() (empty name, none type, no owner)

…get_owner / set_owner)

Add Owner API to the Python SDK to align with the Java client's
getOwner/setOwner methods, enabling ownership management of metadata
objects through the SDK instead of raw REST calls.
@sunyuhan1998
Copy link
Copy Markdown
Contributor Author

@roryqi Hi, could you please help review this PR? Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Python SDK: Add Owner management API (get_owner / set_owner)

1 participant